package com.dubbo.user.consumer;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.dubbo.rpc.RpcContext;
import com.dubbo.order.api.IOrderService;
import com.dubbo.order.api.Requests;
import com.dubbo.order.api.Responses;
 
/**
 * Hello world!
 *  服务调用者
 */

public class App 
{
	public static void main( String[] args ) throws IOException, InterruptedException, ExecutionException {
        ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("order-consumer.xml");

        //用户下单过程
        IOrderService services=(IOrderService)context.getBean("orderServices1");

        Requests request=new Requests();
        request.setName("mic");
       /* Responses response=services.orderSome(request);

        System.out.println(response.toString());

        IOrderQueryService queryService=(IOrderQueryService)context.getBean("orderQueryServices1");
        queryService.orderQuery("hahha");
        
        System.in.read();*/
        
        services.orderSome(request);
        Future<Responses> response = RpcContext.getContext().getFuture();
        System.out.println("AAA");
        Responses response2 = response.get();
        System.out.println(response2);
        
        /**
         * 执行结果
         * AAA
		 * Responses [code=200, message=OK, date=good]
         */
        
        
        
    }
}
